package Day02;

import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        //:输入两个字符串，查找第一个字符串在第二个字符串中出现的次数
        //比如输入dog和 This is a good dog.
        //则出现了一次。
        int count = 0;
        Scanner input = new Scanner(System.in);
        String str = "This is a good dog dog dog";
        char[] charArray = str.toCharArray();
        System.out.println(charArray.length);
        System.out.println("请输入你想查找的字符");
        String in = input.next();
        char c = in.charAt(0);
        for (int i = 0; i < charArray.length; i++) {
            if (c == charArray[i]) {
                count++;
            }
        }
        System.out.println("字符" + in + "出现的次数为：" + count);
    }
}
